package com.cash.app.utils.extra.model

import com.google.gson.annotations.SerializedName
import com.cash.app.utils.extra.tools.CpuUtils
import com.cash.app.utils.extra.tools.OtherUtils
import com.cash.app.utils.extra.tools.OtherUtils.isTabletDevice

class HardwareData {
    @SerializedName("dt_model")
    var model: String? = null

    @SerializedName("dt_brand")
    var brand: String? = null

    @SerializedName("dt_product")
    var product: String? = null

    @SerializedName("dt_release")
    var release: String? = null

    @SerializedName("dt_sdk_version_code")
    var sdk_version_code: String? = null

    @SerializedName("dt_physical_size")
    var physical_size: String? = null

    @SerializedName("dt_cpu_type")
    var cpu_type: String? = null

    @SerializedName("dt_cpu_min")
    var cpu_min: String? = null

    @SerializedName("dt_cpu_max")
    var cpu_max: String? = null

    @SerializedName("dt_cpu_cur")
    var cpu_cur: String? = null

    @SerializedName("dt_manufacturer_name")
    var manufacturer_name: String? = null

    @SerializedName("dt_board")
    var board: String? = null

    @SerializedName("dt_serial_number")
    var serial_number: String? = null

    @SerializedName("dt_display")
    var display: String? = null

    @SerializedName("dt_id")
    var id: String? = null

    @SerializedName("dt_bootloader")
    var bootloader: String? = null

    @SerializedName("dt_finger_print")
    var finger_print: String? = null

    @SerializedName("dt_host")
    var host: String? = null

    @SerializedName("dt_hardware")
    var hardware: String? = null

    @SerializedName("dt_device")
    var device: String? = null

    @SerializedName("dt_user")
    var user: String? = null

    @SerializedName("dt_radio_version")
    var radio_version: String? = null

    @SerializedName("dt_tags")
    var tags: String? = null

    @SerializedName("dt_time")
    var time: String? = null

    @SerializedName("dt_type")
    var type: String? = null

    @SerializedName("dt_base_os")
    var base_os: String? = null

    @SerializedName("dt_baseband_ver")
    var baseband_ver: String? = null

    @SerializedName("dt_resolution")
    var resolution: String? = null

    @SerializedName("dt_screen_density")
    var screen_density: String? = null

    @SerializedName("dt_screen_density_dpi")
    var screen_density_dpi: String? = null

    @SerializedName("dt_cpu_abi")
    var cpu_abi: String? = null

    @SerializedName("dt_cpu_abi2")
    var cpu_abi2: String? = null

    @SerializedName("dt_abis")
    var abis: String = ""

    @SerializedName("dt_is_tablet")
    var is_tablet: Int = 0

    init {
        try {
            model = android.os.Build.MODEL
            brand = android.os.Build.BRAND
            product = android.os.Build.PRODUCT
            release = android.os.Build.VERSION.RELEASE
            sdk_version_code = android.os.Build.VERSION.SDK_INT.toString()
            physical_size = OtherUtils.screenSizeOfDevice2
            cpu_type = CpuUtils.cpuName
            cpu_min = CpuUtils.minCpuFreq
            cpu_max = CpuUtils.maxCpuFreq
            cpu_cur = CpuUtils.curCpuFreq
            manufacturer_name = android.os.Build.MANUFACTURER
            board = android.os.Build.BOARD
            serial_number = OtherUtils.serialNumbers
            display = android.os.Build.DISPLAY
            id = android.os.Build.ID
            bootloader = android.os.Build.BOOTLOADER
            finger_print = android.os.Build.FINGERPRINT
            host = android.os.Build.HOST
            hardware = android.os.Build.HARDWARE
            device = android.os.Build.DEVICE
            user = android.os.Build.USER
            radio_version = android.os.Build.RADIO
            tags = android.os.Build.TAGS
            time = android.os.Build.TIME.toString()
            type = android.os.Build.TYPE
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                base_os = android.os.Build.VERSION.BASE_OS
            }
            baseband_ver = OtherUtils.baseband_Ver
            resolution = OtherUtils.resolutions
            screen_density = OtherUtils.screenDensity.toString()
            screen_density_dpi = OtherUtils.screenDensityDpi.toString()
            cpu_abi = android.os.Build.CPU_ABI
            cpu_abi2 = android.os.Build.CPU_ABI2
            is_tablet = isTabletDevice
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                val supportedAbis = android.os.Build.SUPPORTED_ABIS
                for (i in supportedAbis.indices) {
                    abis += if (i == supportedAbis.size - 1) {
                        supportedAbis[i]
                    } else {
                        supportedAbis[i] + ","
                    }
                }
            }
        } catch (e: java.lang.Exception) {
            e.printStackTrace()
        }
    }

    override fun toString(): String {
        return "HardwareData(" +
                "model=$model, " +
                "brand=$brand, " +
                "product=$product, " +
                "release=$release, " +
                "sdk_version_code=$sdk_version_code, " +
                "physical_size=$physical_size, " +
                "cpu_type=$cpu_type, " +
                "cpu_min=$cpu_min, " +
                "cpu_max=$cpu_max, " +
                "cpu_cur=$cpu_cur, " +
                "manufacturer_name=$manufacturer_name, " +
                "board=$board, " +
                "serial_number=$serial_number, " +
                "display=$display, " +
                "id=$id, " +
                "bootloader=$bootloader, " +
                "finger_print=$finger_print, " +
                "host=$host, " +
                "hardware=$hardware, " +
                "device=$device, " +
                "user=$user, " +
                "radio_version=$radio_version, " +
                "tags=$tags, " +
                "time=$time, " +
                "type=$type, " +
                "base_os=$base_os, " +
                "baseband_ver=$baseband_ver, " +
                "resolution=$resolution, " +
                "screen_density=$screen_density, " +
                "screen_density_dpi=$screen_density_dpi, " +
                "cpu_abi=$cpu_abi, " +
                "cpu_abi2=$cpu_abi2, " +
                "abis='$abis', " +
                "is_tablet=$is_tablet" +
                ")"
    }
}


